home *** CD-ROM | disk | FTP | other *** search
/ CD School House 9 / CD School House 9.0 - Wayzata Technology (1994).iso / pc / dos / math / maplev / demo.in < prev    next >
Text File  |  1992-01-07  |  12KB  |  312 lines

  1. 1910562448
  2. #                        A QUICK TOUR OF MAPLE V
  3. #             Copyright (c) 1991 by Waterloo Maple Software
  4.  
  5. # Maple is an essential tool for anyone who needs to use or study
  6. # mathematics. In the next few screens you will get a glimpse of a few of
  7. # the over 2000 Maple functions and what they can do for you. While this
  8. # Maple Demonstration runs only on an 80386 or 80486 based machine, all
  9. # the Maple commands appearing in this Tour are part of Maple on all
  10. # other platforms including the Macintosh and Unix systems. Only the user
  11. # interface varies from platform to platform.
  12.  
  13. # This demonstration consists of a sequence of descriptive paragraphs
  14. # and Maple commands (which appear after a prompt character). When a
  15. # command appears, press Enter to execute it and display the answer.
  16. # For example, press Enter now:
  17.  
  18. 1 + 2;
  19. # Maple is capable of a wide variety of numeric, graphic, and symbolic
  20. # operations. Maple normally does rational arithmetic. Expressions are
  21. # entered using a syntax similar to that of common programming languages
  22. # such as BASIC, FORTRAN, or Pascal.
  23.  
  24.  
  25. #                          NUMERIC CALCULATIONS
  26.  
  27. # To use Maple as a sophisticated calculator, simply enter the
  28. # calculation you wish to perform on one or more lines. Some of the
  29. # operators available are:  + add,  - subtract,  * multiply,  / divide, ^
  30. # exponentiate, and sqrt() square root. For example:
  31.  
  32. 32 * 12^4;
  33. # Maple recognizes a wide variety of special operators including
  34. # factorial, greatest common divisor, least common multiple, modular
  35. # arithmetic, and so on:
  36.  
  37. 20! - 12!;
  38. # The most recent result (2432902007697638400) can be easily included in
  39. # any subsequent calculation without having to type it. The double-quote
  40. # character (") is used to refer to the last expression computed by
  41. # Maple, in a manner analogous to the use of ditto marks in ordinary
  42. # English. For example, this integer can be separated into its prime
  43. # factors:
  44.  
  45. ifactor(");
  46. # This result can be checked by multiplying it out:
  47.  
  48. expand(");
  49. # Maple's normal mode of computation is exact arithmetic, in which there
  50. # can be no roundoff or truncation errors:
  51.  
  52. (2^30 / 3^20) * sqrt(2);
  53. # But Maple can also provide an approximation in the form of a decimal
  54. # floating point value:
  55.  
  56. evalf(");
  57. # Maple is capable of finding both finite and infinite sums:
  58.  
  59. sum((1+i)/(1+i^4),i=1..20);
  60. # and Maple can do floating-point arithmetic to any desired precision:
  61.  
  62. evalf(",30);
  63. # Maple can do complex arithmetic:
  64.  
  65. evalc((3+5*I)*(7+4*I));
  66. # and compute numeric values for the elementary functions and many
  67. # special functions and constants:
  68.  
  69. evalf(exp(1.0));
  70. evalf(GAMMA(2.5));
  71. evalf(Pi,40);
  72.  
  73. #                2-DIMENSIONAL AND 3-DIMENSIONAL GRAPHICS
  74.  
  75. # Maple supports both 2-dimensional and 3-dimensional graphics. The
  76. # demonstration version supports only EGA or VGA display adapters. The
  77. # full version also supports AT&T, CGA, Hercules, and MCGA displays, and
  78. # EPSON, HP, IBM, Toshiba, and POSTSCRIPT printers.
  79.  
  80. # The Maple plot() command provides support for two-dimensional graphs of
  81. # one or more functions specified as expressions, procedures, parametric
  82. # functions, or lists of points. For example, the following shows the sum
  83. # of two sine curves. Press the Escape key when you are finished viewing
  84. # the plot.
  85.  
  86. plot(sin(x)+sin(5*x),x=-1..4);
  87.  
  88. # The plot3d() command can plot functions of two variables, as well as
  89. # parametric curves or surfaces. The following example plots a simple
  90. # function of two variables:
  91.  
  92. # Once the plot is displayed, you can press the F10 key to display a menu
  93. # that lets you manipulate the plot in various ways. For example,
  94. # pressing F10 to display the menu, followed by V to invoke the View
  95. # item, will let you rotate the plot. After rotating to the desired
  96. # orientation (using the arrow keys), press Escape (to return to the menu),
  97. # and then D to redraw the plot in the new orientation. Other
  98. # manipulations you can perform include adding axes, changing the color
  99. # scheme, changing perspective, and adding a title. The full version also
  100. # lets you create a printed copy of the graph (about 10 different types
  101. # of printers and plotters are supported), or save an image of the graph
  102. # in a file for importing into other programs. Press the Escape key when
  103. # you are finished viewing the plot.
  104.  
  105. plot3d(sin(x)+sin(5*y),x=-1..4,y=-1..4);
  106.  
  107. # Maple also provides a package of functions to generate more complex
  108. # plots easily. This package is called plots, and is loaded using the
  109. # with() command. The package includes functions for plotting in
  110. # spherical and cylindrical coordinates, plotting matrices and complex
  111. # functions, points in space, and many other specialized graphical
  112. # representations. One function in this package (included in the Maple
  113. # Demonstration) is tubeplot(), which plots a parametric curve through
  114. # space, with the thickness of the curve defined by a constant or
  115. # expression. For example (be sure to press the Enter key at the end of
  116. # each line):
  117.  
  118. with(plots):
  119. tubeplot([-10*cos(t)-2*cos(5*t)+15*sin(2*t),
  120.    -15*cos(2*t)+10*sin(t)-2*sin(5*t),
  121.    10*cos(3*t)], t=0..2*Pi, radius=3*cos(t*Pi/3));
  122.  
  123.  
  124. #                          ALGEBRAIC OPERATIONS
  125.  
  126. # Maple is most powerful when working as a symbolic or algebraic
  127. # calculator. First, an expression is entered, and then Maple echoes:
  128.  
  129. (x+y)^3*(x+y)^2;
  130. # In the next four steps the expression is multiplied out, cubed,
  131. # expanded a second time and finally factored:
  132.  
  133. expand(");
  134. "^3;
  135. expand(");
  136. factor(");
  137. # Maple  provides a basic form of simplification for those expressions
  138. # that lie in the domain of rational  functions. The result is expressed
  139. # in the form p/q with the common factors cancelled:
  140.  
  141. normal((x^3-y^3)/(x^2+x-y-y^2));
  142. # More complex simplifications can be accomplished using the simplify()
  143. # command. By using the numer() and denom() commands you can even operate
  144. # on portions of an expression.
  145.  
  146. # In some cases it is useful to define an expression so that it can be
  147. # referred to later. Here e1 is set equal to the quotient of the
  148. # expansion of two expressions. e1 is then simplified:
  149.  
  150. e1 := expand((41*x^2+x+1)^2*(2*x-1)) / expand((3*x+5)*(2*x-1));
  151. normal(e1);
  152. # The convert() operation allows you to convert many types of expressions
  153. # into specific forms. The following example converts an expression into
  154. # a partial fraction:
  155.  
  156. (3*x+5) / (x^2-3*x+2);
  157. convert(",parfrac,x);
  158. # Using the Maple proc() function allows for the definition of
  159. # functions:
  160.  
  161. f1:= proc(x) x^2 end;
  162. # Numeric or symbolic values of the function can be obtained:
  163.  
  164. f1(2);
  165. f1(a+b);
  166. # Functions of several variables or functions that contain more than one
  167. # rule can be defined:
  168.  
  169. f2:= proc(x) if x > 3 then x^2 else if x <= 3 then x-5 fi fi end;
  170. f2(0);
  171.  
  172. #               SOLVING EQUATIONS AND SYSTEMS OF EQUATIONS
  173.  
  174. # You can use Maple to solve algebraic equations (or expressions assumed
  175. # to be equal to zero):
  176.  
  177. x^3-1/2*x^2*a+13/3*x^2-13/6*x*a-10/3*x+5/3*a;
  178. solve(",x);
  179. # Maple can also solve systems of equations:
  180.  
  181. eqn1 := x + 2*y + 3*z + 4*t + 5*u = 6;
  182. eqn2 := 5*x + 5*y + 4*z + 3*t + 2*u = 1;
  183. eqn3 := 3*y + 4*z - 8*t + 2*u = 1;
  184. eqn4 := x + y + z + t + u = 9;
  185. eqn5 := 8*x + 4*z + 3*t + 2*u = 1;
  186. solutions1 := solve({eqn.(1..5)}, {x,y,z,t,u});
  187. # You can also choose to solve an under-constrained set of equations:
  188.  
  189. solutions2 := solve({eqn.(1..4)}, {x,y,z,t,u});
  190. # Since exact symbolic arithmetic is performed, Maple can recognize
  191. # equations that are linearly dependent. The set of under-constrained
  192. # equations (eqn1 ... eqn4) produces a set of solutions in which the
  193. # equation t = t appears. This means that t can take arbitrary values.
  194.  
  195. # We can check the solutions produced by substituting the values given
  196. # for x, y, z, t, and u into the original set of of equations.
  197. # This set of invariants confirms the validity of the answer that was
  198. # computed by the solve command:
  199.  
  200. subs(solutions2,{eqn.(1..4)});
  201.  
  202. #                                CALCULUS
  203.  
  204. # Maple is an outstanding tool for working with calculus. You will be
  205. # able to compute limits as well as integrate and differentiate:
  206.  
  207. f := (x^2-2*x+1)/(x^4+3*x^3-7*x^2+x+2);
  208. limit(f,x=1);
  209. f := (2*x+3)/(7*x+5);
  210. limit(f,x=infinity);
  211. f := x*sin(x) + 2*x^2;
  212. diff(f,x);
  213. int(",x);
  214. # A wide variety of examples showing the use of Maple in the study of
  215. # calculus can be found in Maple for the Calculus Student, A Tutorial by
  216. # Wade Ellis and Ed Lodi. This inexpensive supplement is available from
  217. # Brooks/Cole. The following example is from Maple for the Calculus
  218. # Student:
  219.  
  220. #       Maple can solve many differential equations as explicit
  221. #       functions (in closed form). When necessary, it can give
  222. #       approximate numerical solutions to such equations. In addition,
  223. #       Maple provides a Laplace transform capability that can be used
  224. #       in solving differential equations.
  225.  
  226. #       Maple can easily solve the differential equation y' = y:
  227.  
  228. dsolve(diff(y(x),x) - y(x) = 0, y(x));
  229.  
  230. #                           MATRIX OPERATIONS
  231.  
  232. # Maple comes with a wide variety of special packages. Among these is the
  233. # Linear Algebra Package. This package has a complete set of commands for
  234. # working in linear algebra and other areas that involve matrices,
  235. # arrays, and determinants. Loading the Linear Algebra Package is
  236. # accomplished as follows:
  237.  
  238. with(linalg):
  239.  
  240. # Once the package is resident, many additional commands are available
  241. # (only a few of them are available in the Demonstration). Here we define
  242. # a 2-by-2 symbolic array:
  243.  
  244. M := array(1...2,1...2);
  245. # Then find its determinant:
  246.  
  247. det(M);
  248. # Next, let Maple define a special matrix, find the inverse of that
  249. # matrix, and finally multiply those matrices together to obtain the
  250. # identity matrix as a check:
  251.  
  252. H := hilbert(5);
  253. H1 := inverse(H);
  254. multiply(H,H1);
  255. # In the following three commands, Maple will generate a 3-by-3 matrix
  256. # that has some symbolic entries, take its determinant, and finally
  257. # factor that determinant:
  258.  
  259. V := vandermonde([u,v,w]);
  260. d := det(V);
  261. factor(d);
  262.  
  263. #                              ON-LINE HELP
  264.  
  265. # Maple contains a complete on line help system. The following command
  266. # will display an index of Maple command categories (when you are done
  267. # looking at the help file, press the Escape key):
  268.  
  269. ?index
  270.  
  271. # The ? command invokes the help browser to display information about the
  272. # selected topic. Users of older versions of Maple will be interested in
  273. # knowing that the ? command does not require reserved words, symbols, or
  274. # assigned names to be quoted, as the help() procedure requires.
  275.  
  276. # When the browser is displaying information about a topic, you can
  277. # browse through this information using the cursor movement keys. Lines
  278. # containing Maple statements can be selected, and pasted into your Maple
  279. # session and executed. The full version of Maple also lets you edit
  280. # these lines before pasting them into the session.
  281.  
  282. # The help system includes the complete definition of syntax and
  283. # description of function, as well as examples. Here are two more
  284. # examples of on-line help (remember to press Escape when you are done
  285. # with each one):
  286.  
  287. ?ifactor
  288. ?plot3d
  289.  
  290. # If you do not know the topic you wish to read about, pressing F1 during
  291. # your Maple session will display a hierarchy of topics from which you can
  292. # select. The demonstration version supports this feature, but the
  293. # information for all but three of the topics is not included on the
  294. # demonstration diskette. Try pressing F1 now.
  295.  
  296. # ------------------------------------------------------------------------
  297. #              For more information, or to order, contact:
  298.  
  299. #                     Brooks/Cole Publishing Company
  300. #                         511 Forest Lodge Road
  301. #                        Pacific Grove, CA 93950
  302.  
  303. #                        To order: (800) 354-9706
  304. #                Information and Support: (408) 373-0728
  305. #                          Fax: (408) 375-6414
  306.  
  307. #                E-mail: brooks.cole@applelink.apple.com
  308. # ------------------------------------------------------------------------
  309.  
  310. # You can now try some more Maple commands (you can recall and edit earlier
  311. # commands using the arrow keys), or press F3 to return to DOS.
  312.